﻿<UserControl x:Class="Presentation.ReportPanneView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:inf="clr-namespace:Presentation.Infrastructure"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             Style="{StaticResource CommonViewStyle}">
    <UserControl.Resources>

        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <inf:ObjetPatrimonialDTOStateConverter x:Key="ObjetPatrimonialDTOStateConverter" />
        <inf:PanneDTOSeverityConverter x:Key="PanneDTOSeverityConverter" />
        
        <Style x:Key="TitleStyle"
               TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground"
                    Value="White"></Setter>
            <Setter Property="FontFamily"
                    Value="Segoe UI"></Setter>
            <Setter Property="FontSize"
                    Value="20"></Setter>
            <Setter Property="Margin"
                    Value="0,5,0,5"></Setter>
        </Style>  

        <DataTemplate x:Key="ObjetPatrimonialTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                
                <Border Padding="3">                    
                    <TextBlock FontWeight="SemiBold">
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{}{0} ({1} ans)">
                                <Binding Path="Label"></Binding>
                                <Binding Path="Age"></Binding>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </Border>

                <TextBlock Grid.Row="1" 
                           Text="{Binding Path=Town, StringFormat=Ville : {0}}"></TextBlock>

                <TextBlock Grid.Row="2"
                           Text="{Binding Path=State, Converter={StaticResource ObjetPatrimonialDTOStateConverter}}"></TextBlock>

            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="PanneTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>

                <Border Padding="3">
                    <TextBlock FontWeight="SemiBold" Text="{Binding Label}"></TextBlock>
                </Border>

                <TextBlock Grid.Row="1"
                           Text="{Binding Path=Severity, StringFormat=Séverité : {0}, Converter={StaticResource PanneDTOSeverityConverter}}"></TextBlock>
            </Grid>
        </DataTemplate>

        <Style x:Key="ObjetPatrimonialItemStyle"
               TargetType="{x:Type ListBoxItem}">
            <Setter Property="ContentTemplate"
                    Value="{StaticResource ObjetPatrimonialTemplate}"></Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="Bd" 
                                Margin="2,0,2,0" 
                                Padding="5"
                                Background="#66E4008C">
                            <ContentPresenter></ContentPresenter>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver"
                                     Value="True"
                                     SourceName="Bd">
                                <Trigger.Setters>
                                    <Setter Property="Background"
                                            Value="#e4008c"
                                            TargetName="Bd"></Setter>
                                </Trigger.Setters>
                            </Trigger>
                            <Trigger Property="IsSelected"
                                     Value="True">
                                <Trigger.Setters>
                                    <Setter Property="Background"
                                            Value="#e4008c"
                                            TargetName="Bd"></Setter>
                                </Trigger.Setters>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="PanneItemStyle"
               TargetType="{x:Type ListBoxItem}">
            <Setter Property="ContentTemplate"
                    Value="{StaticResource PanneTemplate}"></Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="Bd"
                                Margin="2,0,2,0"
                                Padding="5"
                                Background="#67F16C00">
                            <ContentPresenter></ContentPresenter>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver"
                                     Value="True"
                                     SourceName="Bd">
                                <Trigger.Setters>
                                    <Setter Property="Background"
                                            Value="#f16c00"
                                            TargetName="Bd">
                                    </Setter>
                                </Trigger.Setters>
                            </Trigger>
                            <Trigger Property="IsSelected"
                                     Value="True">
                                <Trigger.Setters>
                                    <Setter Property="Background"
                                            Value="#f16c00"
                                            TargetName="Bd"></Setter>
                                </Trigger.Setters>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <Grid Margin="10,10,5,10">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>

            <TextBlock Text="1. Sélectionnez l'objet en panne"
                       Style="{StaticResource TitleStyle}"></TextBlock>
            <ListBox Grid.Row="1"
                     Style="{StaticResource HorizontalMetroListBoxStyle}"
                     ItemsSource="{Binding ObjetPatrimonialCollection}"
                     SelectedItem="{Binding SelectedObjetPatrimonial}"
                     ItemContainerStyle="{StaticResource ObjetPatrimonialItemStyle}">
            </ListBox>

            <TextBlock Grid.Row="2"
                       Text="2. Sélectionnez la panne à signaler"
                       Style="{StaticResource TitleStyle}"></TextBlock>
            <ListBox Grid.Row="3"
                     Style="{StaticResource HorizontalMetroListBoxStyle}"
                     ItemsSource="{Binding PanneCollection}"
                     SelectedItem="{Binding SelectedPanne}"
                     ItemContainerStyle="{StaticResource PanneItemStyle}"></ListBox>

            <TextBlock Grid.Row="4"
                       Text="3. Saisir un commentaire"
                       Style="{StaticResource TitleStyle}"></TextBlock>
            <TextBox Grid.Row="5"
                    MinHeight="80" FontFamily="Segoe UI" FontSize="15"
                    BorderBrush="#723989" BorderThickness="1"
                    Text="{Binding Comments}">
                <TextBox.Background>
                    <SolidColorBrush Color="#723989" Opacity="0.5"></SolidColorBrush>
                </TextBox.Background>

            </TextBox>
        </Grid>

        <StackPanel Grid.Column="1" Margin="5,10,5,5">
            <Border Margin="0,0,0,5"
                    Padding="5"
                    VerticalAlignment="Top">
                <Button Content="Créer"
                        Command="{Binding CreateSignalementCommand}"
                        HorizontalAlignment="Left"></Button>
            </Border>

            <Border Margin="0,0,0,5"
                    Padding="5"
                    VerticalAlignment="Top">
                <Button Content="Retour"
                        Command="{Binding CancelCommand}"
                        HorizontalAlignment="Left"></Button>
            </Border>
            
        </StackPanel>

        <Border Grid.ColumnSpan="2"
            Visibility="{Binding IsDialogVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Border.Background>
                <SolidColorBrush Color="Black" Opacity="0.7"></SolidColorBrush>
            </Border.Background>

            <Border BorderBrush="White" BorderThickness="2" CornerRadius="3"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center">
                <Border.Background>
                    <LinearGradientBrush>
                        <GradientStop Color="#38004D"
                                      Offset="0"></GradientStop>
                        <GradientStop Color="#52156A"
                                      Offset="1"></GradientStop>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid Margin="10">
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="5"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Veuillez saisir la date de constat :" FontSize="16"></TextBlock>
                    <TextBox Grid.Column="2"
                             Text="{Binding ObservationDate, Mode=TwoWay, StringFormat={}{0:dd/MM/yyyy}}"
                             MinWidth="100"></TextBox>
                    
                    <Border Grid.Row="1" 
                            Grid.Column="2"
                            Padding="5"
                            HorizontalAlignment="Right">
                        <Button Content="Créer le signalement"
                                Command="{Binding ConfirmCreateSignalementCommand}"
                                HorizontalAlignment="Right"></Button>
                    </Border>
                </Grid>
            </Border>      
                        
        </Border>

    </Grid>

</UserControl>
